package com.kws.merchant.service.impl;


import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.kws.merchant.domain.MessageNotification;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kws.merchant.domain.po.MessageNotificationPo;
import com.kws.merchant.mapper.MessageNotificationMapper;
import com.kws.merchant.service.MessageNotificationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;

/**
 * 消息通知(MessageNotification)表服务实现类
 *
 * @author yxy
 * @since 2024-10-29 14:45:43
 */
@Service("messageNotificationService")
public class MessageNotificationServiceImpl extends ServiceImpl<MessageNotificationMapper, MessageNotification> implements MessageNotificationService {

    @Resource
    private MessageNotificationMapper messageNotificationMapper;


    /**
     * 分页查询列表
     */
    @Override
    public Page<MessageNotification> pageList(MessageNotificationPo messageNotificationPo) {
        Page<MessageNotification> page = new Page<>(messageNotificationPo.getPageSize(), messageNotificationPo.getTotalPage());
        LambdaQueryWrapper<MessageNotification> queryWrapper = Wrappers.lambdaQuery();
        String content = messageNotificationPo.getContent();//消息内容
        String type = messageNotificationPo.getType();//消息类型
        String status = messageNotificationPo.getStatus();//0已读 1未读
        if (StringUtils.isNotEmpty(content)){
            queryWrapper.eq(MessageNotification::getContent,content);
        }
        if (StringUtils.isNotEmpty(type)){
            queryWrapper.eq(MessageNotification::getType,type);
        }
        if (StringUtils.isNotEmpty(status)){
            queryWrapper.eq(MessageNotification::getStatus,status);
        }
        return this.page(page, queryWrapper);
    }


}
